package jspSamples.unit5.javaBeanSamples;

public class shixun5_1Calculater {
    float num1;//参数1
    int operator;//运算符
    float num2;//参数2
    float result;//运算结果
    public shixun5_1Calculater(){
        super();
    }

    public float getNum1() {
        return num1;
    }

    public void setNum1(float num1) {
        this.num1 = num1;
    }

    public int getOperator() {
        return operator;
    }

    public void setOperator(int operator) {
        this.operator = operator;
    }

    public float getNum2() {
        return num2;
    }

    public void setNum2(float num2) {
        this.num2 = num2;
    }

    public float getResult() {
        float result = 0;
        try{
            switch (operator){
                case 1://1代表+
                    result = num1 + num2;
                    break;
                case 2://2代表1
                    result = num1 - num2;
                    break;
                case 3://13代表*
                    result = num1 * num2;
                    break;
                case 4://4代表、
                    result = num1 / num2;
                    break;
            }
        }catch (Exception e){
            e.getMessage();
        }
        return result;
    }

}
